package com.suyuan.controller;


import com.suyuan.entity.TestBean;
import com.suyuan.service.TestService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by yang on 2018/1/2.
 */
@Controller
@RequestMapping(value="/test")
public class TestController {

    @Resource(name = "testService")
    private TestService testService;

    @RequestMapping(value = "/")
    public String test1(ModelMap map){
        System.out.println("11111");
        List<TestBean> list = testService.test1();
        System.out.println(list.get(0).getName());
        map.addAttribute("name",list.get(0).getName());
        return "test";
    }

    /*@RequestMapping(value="/{html}")
    public String jump(@PathVariable String html){
        System.out.println("page:"+html);
        return html;
    }*/


    /**
     * 使用通用mapper查询数据库全部user对象
     * @return
     */
    /*@RequestMapping(value="userList")
    public String test3(){
        List<User> users = testService.getUserList();
        System.out.println("count:"+users.size());
        for (User user: users) {
            System.out.println("user name :"+user.getUsername());
        }
        return "jsp/index1";
    }*/

    /**
     * 使用PageHelper查询分页信息
     * @return
     */
    /*@RequestMapping(value="userByPage")
    public String test4(){
        List<User> users = testService.getUserByPage();
        for (User user:users) {
            System.out.println("user:"+user.getUsername());
        }
        return "jsp/index1";
    }*/


    public String test2(){
        return "hahsadasda";

    }


    /*@RequestMapping(value = "/test3")
    public void test3(){
        CarInfo car = new CarInfo();
        car.setCarId(1);
        car.setLicenseNumber("123123");

        JedisClientPool client = new JedisClientPool();
        client.set("test3",JsonUtils.objectToJson(car));

        String value = client.get("test3");
        System.out.println("test3:"+value);
    }*/

    /**
     * jedisPool测试类
     */
    /*@Autowired
    private JedisClientPool jedisClientPool;

    @RequestMapping(value = "/test4")
    public String test4(){
        CarInfo car = new CarInfo();
        car.setCarId(1);
        car.setLicenseNumber("123123");

        *//*JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(300);
        config.setMaxTotal(600);
        config.setMaxWaitMillis(10000);
        config.setTestOnBorrow(true);
        JedisPool pool = new JedisPool(config,"192.168.0.106",6379);*//*

        //Jedis jedis = new Jedis("192.168.0.106",6379);
        jedisClientPool.set("test4",JsonUtils.objectToJson(car));
        System.out.println("test4:"+jedisClientPool.get("test4"));

        return "test";
    }
*/
}
